package modelo;

import java.io.Serializable;
import javax.persistence.*;

import java.util.Date;

/**
 * The persistent class for the reserva database table.
 * 
 */
@Entity
@NamedQueries({
		@NamedQuery(name = "Reserva.seleccionarPorDobleId", query = "select p from Reserva p "
				+ "where p.id.dni = :dni and p.id.idPista = :id_pista"),
		@NamedQuery(name = "Reserva.seleccionarReservasPorUsuario", query = "select p from Reserva p "
				+ "where p.id.dni = :dni"),
		@NamedQuery(name = "Reserva.seleccionarReservasPorPista", query = "select p from Reserva p "
				+ "where p.id.idPista = :id_pista"),
		@NamedQuery(name = "Reserva.seleccionarReservasPorHorario", query = "select p from Reserva p "
				+ "where p.horario.idHorario = :id_horario"),
		@NamedQuery(name = "Reserva.seleccionarTodasReservas", query = "select p from Reserva p "),
		@NamedQuery(name = "Reserva.disponibilidadPista", query = "select p from Reserva p "
				+ "where p.id.idPista = :id_pista AND p.fechaReservada = CURRENT_DATE AND p.horario.idHorario in (1,2,3,4,5,6)")
})
@Table(name = "reserva")
public class Reserva implements Serializable {
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private ReservaPK id;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "fecha_reserva", nullable = false)
	private Date fechaReserva;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "fecha_reservada", nullable = false)
	private Date fechaReservada;

	// bi-directional many-to-one association to Horario
	@ManyToOne
	@JoinColumn(name = "id_horario", nullable = false)
	private Horario horario;

	// bi-directional many-to-one association to Pista
	@ManyToOne
	@JoinColumn(name = "id_pista", nullable = false, insertable = false, updatable = false)
	private Pista pista;

	// bi-directional many-to-one association to Usuario
	@ManyToOne
	@JoinColumn(name = "dni", nullable = false, insertable = false, updatable = false)
	private Usuario usuario;

	public Reserva() {
	}

	public ReservaPK getId() {
		return this.id;
	}

	public void setId(ReservaPK id) {
		this.id = id;
	}

	public Date getFechaReserva() {
		return this.fechaReserva;
	}

	public void setFechaReserva(Date fechaReserva) {
		this.fechaReserva = fechaReserva;
	}

	public Date getFechaReservada() {
		return this.fechaReservada;
	}

	public void setFechaReservada(Date fechaReservada) {
		this.fechaReservada = fechaReservada;
	}

	public Horario getHorario() {
		return this.horario;
	}

	public void setHorario(Horario horario) {
		this.horario = horario;
	}

	public Pista getPista() {
		return this.pista;
	}

	public void setPista(Pista pista) {
		this.pista = pista;
	}

	public Usuario getUsuario() {
		return this.usuario;
	}

	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}

}